package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BuzTaskArea;
import com.ruoyi.system.service.IBuzTaskAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动参与的地区Controller
 * 
 * @author ruoyi
 * @date 2023-08-27
 */
@RestController
@RequestMapping("/system/buzTaskArea")
public class BuzTaskAreaController extends BaseController
{
    @Autowired
    private IBuzTaskAreaService buzTaskAreaService;

    /**
     * 查询活动参与的地区列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskArea:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzTaskArea buzTaskArea)
    {
        startPage();
        List<BuzTaskArea> list = buzTaskAreaService.selectBuzTaskAreaList(buzTaskArea);
        return getDataTable(list);
    }

    /**
     * 导出活动参与的地区列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskArea:export')")
    @Log(title = "活动参与的地区", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzTaskArea buzTaskArea)
    {
        List<BuzTaskArea> list = buzTaskAreaService.selectBuzTaskAreaList(buzTaskArea);
        ExcelUtil<BuzTaskArea> util = new ExcelUtil<BuzTaskArea>(BuzTaskArea.class);
        util.exportExcel(response, list, "活动参与的地区数据");
    }

    /**
     * 获取活动参与的地区详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskArea:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(buzTaskAreaService.selectBuzTaskAreaById(id));
    }

    /**
     * 新增活动参与的地区
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskArea:add')")
    @Log(title = "活动参与的地区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzTaskArea buzTaskArea)
    {
        return toAjax(buzTaskAreaService.insertBuzTaskArea(buzTaskArea));
    }

    /**
     * 修改活动参与的地区
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskArea:edit')")
    @Log(title = "活动参与的地区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzTaskArea buzTaskArea)
    {
        return toAjax(buzTaskAreaService.updateBuzTaskArea(buzTaskArea));
    }

    /**
     * 删除活动参与的地区
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskArea:remove')")
    @Log(title = "活动参与的地区", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buzTaskAreaService.deleteBuzTaskAreaByIds(ids));
    }
}
